package com.searchparking.BUS;

import java.util.ArrayList;

import com.searchparking.R;
import com.searchparking.DTO.InfoObject;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListviewAdapter extends BaseAdapter {
	public Context context;

	ArrayList<InfoObject> arr ;
	public ListviewAdapter(Context context, ArrayList<InfoObject> arrayList) {
		this.context = context;
		arr = new ArrayList<InfoObject>();
		arr = arrayList;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arr.size();
	}
	public void addItem(InfoObject a){
		arr.add(a);
	}
	@Override
	public InfoObject getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) context
					.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.view_search_row, null);
		}
		TextView number = (TextView) convertView.findViewById(R.id.tvnumber_park);
		TextView address = (TextView) convertView.findViewById(R.id.tvaddress);
		TextView emptynum = (TextView) convertView.findViewById(R.id.tvPositionEmty);
		InfoObject obj= arr.get(position);
		number.setText(obj.getId());
		address.setText(obj.getAddr());
		emptynum.setText(String.valueOf(obj.getStatus()));
		return convertView;
	}

}
